package com.ruoyi.web.controller.construction.supertube;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.zhuangxiumain.financialSupport.CooperativeBrand;
import com.ruoyi.system.domain.zhuangxiumain.financialSupport.ProductSuperiority;
import com.ruoyi.system.service.vantservice.financialSupport.ApiProductSuperiorityService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 产品图片控制层
 */
@RestController
@RequestMapping("super/SuperProductSuperiorityController")
public class SuperProductSuperiorityController extends BaseController {

    @Autowired
    private ApiProductSuperiorityService productSuperiorityService;

    /**
     * 获取产品图片
     * @return
     */
    @GetMapping("/getSuperiority")
    public TableDataInfo getSuperiority()  {
        startPage();
        List<ProductSuperiority> list = productSuperiorityService.selectProductSuperiorityByNull();
        return getDataTable(list);
    }

    /**
     * 增加产品图片
     * @param productSuperiority
     * @return
     */
    @ApiResponses({@ApiResponse(code = 200, message = "正常", response = ProductSuperiority.class)})
    @ApiOperation(value = "新增产品优势")
    //@PreAuthorize("@ss.hasPermi('shopping:goods:addpi')")
    @Log(title = "新增产品优势", businessType = BusinessType.INSERT)
    @PostMapping("/addProductSuperiority")
    public AjaxResult addProductSuperiority(@RequestBody ProductSuperiority productSuperiority){
        productSuperiority.setSuperiorityState("1");
        return AjaxResult.success(productSuperiorityService.addProductSuperiority(productSuperiority));
    }
    @ApiResponses({@ApiResponse(code = 200, message = "正常", response = ProductSuperiority.class)})
    @ApiOperation(value = "修改产品优势")
    //@PreAuthorize("@ss.hasPermi('shopping:goods:addpi')")
    @Log(title = "修改产品优势", businessType = BusinessType.UPDATE)
    @PutMapping("/updateProductSuperiority")
    public AjaxResult putProductSuperiority(@RequestBody ProductSuperiority productSuperiority){
        return AjaxResult.success(productSuperiorityService.updateProductSuperiority(productSuperiority));
    }

    @ApiOperation(value = "删除产品优势")
    //@PreAuthorize("@ss.hasPermi('shopping:goods:addpi')")
    @Log(title = "删除产品优势", businessType = BusinessType.UPDATE)
    @DeleteMapping("/deleteProductSuperiority/{superiorityIds}")
    public AjaxResult deleteProductSuperiority(@PathVariable Integer[] superiorityIds){
        return AjaxResult.success(productSuperiorityService.deleteProductSuperiority(superiorityIds));
    }
}
